<template>
	<view class="container">
		<view class="box">
			<view class="title">
				我的宠物
			</view>
			<scroll-view scroll-x="true">
				<view class="grid">
					<view @click="goEdit(index)" class="grid-item" v-for="(item,index) in petList" :key="index">
						<image :src="item.pet_avatur"></image>
						<view class="name">{{item.pet_name}}</view>
					</view>
					<view @click="goAdd()" class="grid-item">
						<image src="../../../static/user/add.png"></image>
						<view style="color: #9c9c9c;" class="name">添加宠物</view>
					</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script lang="ts" setup>
	import {ref,reactive} from "vue"
	import {onShow} from "@dcloudio/uni-app"
	onShow(()=>{
		petList.value=uni.getStorageSync('petlist')
		console.log(petList.value)
	})
	
	let petList=ref([])
	function goAdd(){
		uni.navigateTo({
			url:'/pages/user/pet/add'
		})
	}
	function goEdit(index){
		uni.navigateTo({
			url:'/pages/user/pet/edit?index='+index
		})
	}
</script>

<style lang="scss">
	.container{
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		
		.box{
			width: 95%;
			box-sizing: border-box;
			padding: 20rpx;
			border-radius: 30rpx;
			background-color: #ffffff;
			
			.title{
				font-size: 32rpx;
				font-weight: 600;
				letter-spacing: 0.1em;
				margin-bottom: 20rpx;
			}
			
			.grid{
				display: flex;
				
				&-item{
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;
					margin-right: 30rpx;
					
					image{
						width: 100rpx;
						height: 100rpx;
						border-radius:50%;
						margin-bottom: 10rpx;
					}
					
					.name{
						letter-spacing: 0.1em;
						font-size: 28rpx;
					}
				}
			}
		}
	}
</style>
